<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>星球银河 - 留言中心</title>
    <link href="/public/index/css/bootstrap.min.css" rel="stylesheet">
    <link href="/public/index/css/font-awesome.min.css" rel="stylesheet">
    <link href="/public/index/css/toastr.min.css" rel="stylesheet">
    <link href="/public/index/css/jquery.gritter.css" rel="stylesheet">
    <link href="/public/index/css/animate.css" rel="stylesheet">
    <link href="/public/index/css/style.css" rel="stylesheet">
    <link href="/public/index/css/loaders.css" rel="stylesheet">
    <link href="/public/index/css/all.css" rel="stylesheet">
    <link href="/public/index/css/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/index/css/ladda-themeless.min.css" rel="stylesheet">
    <style type="text/css">body{background-size:30%;}.fixed-table-pagination{margin-left:20px;margin-right:12px;}@-webkit-keyframes bell{0%{filter:grayscale(0) blur(3px);color:#ec7063;}10%{filter:grayscale(0) blur(2px);color:#ec7063;}30%{filter:grayscale(0) blur(1px);color:#ec7063;}100%{filter:grayscale(0) blur(0px);color:#ec7063;}}#bell{}.nav-fix{display:inline-block!important;font-size:14px;}</style>
</head>
<body>
<div id="wrapper">
    {include file="Include/left" /}
    <div id="page-wrapper" class="gray-bg">
        {include file="Include/right" /}
        <link href="/public/index/css/sweetalert.css" rel="stylesheet">
        <div class="wrapper wrapper-content animated fadeInUp">
            <style type="text/css">.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#fff;opacity:1;}</style>
            <style type="text/css">input[type=checkbox],input[type=radio]{margin:4px 0 0 !important;margin-top:1px 9;line-height:normal;width:26px;height:26px}</style>
            <div class="row animated fadeInDown" id="detail">
                <div class="col-lg-12">
                    <div class="ibox-title">
                        <h5>留言列表</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="#">Config option 1</a>
                                </li>
                                <li><a href="#">Config option 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <a href="javascript:history.back(-1);">
                        <button class="btn btn-primary" onclick="list();">返回留言列表</button>
                        </a>
                        <br/>
                        <form method="post" class="form-horizontal" action onsubmit="return false">
                            <div class="hr-line-dashed"></div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-lg-2 control-label">标题</label>
                                <div class="col-lg-10">
                                    <input id="title" type="text" class="form-control">
                                </div>
                            </div>
                            <div class="form-group"><label class="col-lg-2 control-label">留言内容</label>
                                <div class="col-lg-10">
                                    <textarea id="content" type="text" class="form-control"></textarea>
                                    <span class="help-block m-b-none" id="result">

                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button id="submit" class="ladda-button ladda-button-demo btn btn-primary" type="button"
                                            data-style="zoom-in" onclick="to_submit()">提交留言</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        {include file="Include/foot" /}
        <script type="text/javascript">
            $("#content").keyup(function(){
                var length =200;var content_len =$("#content").val().length;
                var in_len =length-content_len;
                if(in_len >=0){$("#result").html('您还可以输入'+in_len+'字');
                    $("#submit").attr("disabled",false);}else{$("#result").html('内容超出字数限制');
                    $("#submit").attr("disabled",true);}
            });
            function to_submit()
            {
                var title = $("#title").val();
                var content = $("#content").val();
                if(title == '' || content == ''){
                    layer.msg('不能为空！');
                }else{
                    $.ajax({
                        url: "{:Url('Message/message_add')}",
                        type: "POST",
                        data: {'title':title,'content':content},
                        success: function (data) {
                            if(data.status){
                                layer.msg(data.msg);
                                setTimeout(function () {window.location.href = "{:Url('Message/message')}"},1000);
                            }else{
                                layer.msg(data.msg);
                                setTimeout(function () {window.location.href = "{:Url('Message/message')}"},1000);
                            }
                        }
                    });
                }
            }
        </script>
</body>
</html>
